Proper connect_port
[juce-lv2.git] / juce / source / extras / the jucer / src / model / jucer_BinaryResources.h
blobbbf12926d78aa9bd59c1e1c9fc79448680e202c8
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCER_BINARYRESOURCES_JUCEHEADER__
27 #define __JUCER_BINARYRESOURCES_JUCEHEADER__
29 class JucerDocument;
32 //==============================================================================
33 /**
34 Manages a list of binary data objects that a JucerDocument wants to embed in
35 the code it generates.
37 class BinaryResources
39 public:
40 //==============================================================================
41 BinaryResources();
42 ~BinaryResources();
44 BinaryResources& operator= (const BinaryResources& other);
46 void loadFromCpp (const File& cppFileLocation, const String& cpp);
48 //==============================================================================
49 struct BinaryResource
51 BinaryResource();
52 ~BinaryResource();
54 String name;
55 String originalFilename;
56 MemoryBlock data;
57 Drawable* drawable;
60 void clear();
61 bool add (const String& name, const File& file);
62 void add (const String& name, const String& originalFileName, const MemoryBlock& data);
63 void remove (const int index);
64 bool reload (const int index);
65 const String browseForResource (const String& title, const String& wildcard,
66 const File& fileToStartFrom, const String& resourceToReplace);
68 const String findUniqueName (const String& rootName) const;
70 int size() const throw() { return resources.size(); }
71 const BinaryResource* operator[] (const int index) const throw() { return resources [index]; }
73 const BinaryResource* getResource (const String& resourceName) const;
74 const BinaryResource* getResourceForFile (const File& file) const;
76 const StringArray getResourceNames() const;
78 const Drawable* getDrawable (const String& name) const;
79 const Image getImageFromCache (const String& name) const;
81 template <class ElementComparator>
82 void sort (ElementComparator& sorter)
84 resources.sort (sorter, true);
85 changed();
88 //==============================================================================
89 void setDocument (JucerDocument* const document_) { document = document_; }
90 JucerDocument* getDocument() const throw() { return document; }
92 void fillInGeneratedCode (GeneratedCode& code) const;
95 private:
96 //==============================================================================
97 JucerDocument* document;
98 OwnedArray <BinaryResource> resources;
100 BinaryResource* findResource (const String& name) const throw();
101 void changed();
105 #endif // __JUCER_BINARYRESOURCES_JUCEHEADER__